import echarts from 'echarts'
export const barParams = (xOptionData, alarmOptionData, seriesName, color , rotate) => {
  const { clientWidth:w } = document.body
  let rotatenum = 0
  if (rotate) {
    rotatenum = rotate
  }
  return {
    title: {},
    tooltip: {
      trigger: 'axis',
      backgroundColor:'#192b41'
    },
    grid: {
      top:'45',
      left: '5%',
      right:'5%',
      bottom: '8%',
      containLabel: true
    },
    dataZoom: [
      {
        type: 'inside',
        throttle: 100
      }
    ], 
    xAxis: {
      data: xOptionData,
      axisTick: {
        show: false
      },
      axisLabel: {
        rotate:rotatenum,
      },

      axisLine: {
        lineStyle: {
          color: '#808080' // 更改坐标轴颜色
        }
      }
    },
    yAxis: [
      {
        name: '次数       ',
        type: 'value',
        axisLine: {
          // 轴线
          show: false
        },
        splitLine: { lineStyle: { color: ['#3E5066'] } }, // 网格线颜色
        axisTick: {
          show: false
        },
        minInterval: 1,
        axisLabel: {
          // 轴标
          textStyle: {
            color: '#B7C0C7', // 更改坐标轴文字颜色
            fontSize: w/1920 * 11 // 更改坐标轴文字大小
          }
        },
        nameTextStyle: {
          color: '#B7C0C7',
          padding: [0, 0, 10, 0]
        }
      }
    ],
    series: {
      name: seriesName,
      data: alarmOptionData,
      smooth: true,
      type: 'bar',
      color,
      barWidth: w/1920 * 30,
      itemStyle: {      
        normal: {
          //柱形图圆角，初始化效果
          barBorderRadius:[w/1920 * 30, w/1920 * 30, 0, 0],
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: 'rgba(114,197,241,0.8)' },
            { offset: 0.5, color: 'rgba(78,132,168,0.8)' },
            { offset: 1, color: 'rgba(51,82,110,0.8)' }
          ])
        }
      }
    }
  }
}